#include "stdafx.h"
#include "TestMgr.h"
#include "Test.h"

using namespace Base::UnitTest;

TestMgr::TestMgr()
{
}

TestMgr::~TestMgr()
{
}

TestMgr*
TestMgr::get()
{
    static TestMgr theInstance;
    return &theInstance;
}

void
TestMgr::run(const std::wstring& exePath)
{
    m_exePath = exePath;

    for (unsigned int i = 0; i < m_tests.size(); ++i)
    {
        m_tests[i]->run();
    }
}

void
TestMgr::addTest(Test* test)
{
    assert(test && !hasTest(test));
    m_tests.push_back(test);
}

bool
TestMgr::hasTest(Test* test) const
{
    assert(test);
    Tests::const_iterator it = std::find(m_tests.begin(), m_tests.end(), test);
    return (it != m_tests.end());
}

const std::wstring&
TestMgr::exePath() const
{
    return m_exePath;
}